import { useEffect, useState } from 'react'
import classnames from 'classnames';
import { Space, Select, message, Divider } from 'antd';
import moment from 'moment'
import {
  reqPulseCalibrationList,
  reqTongueCalibrationList,
  reqDiagnosisTermList,
  reqDiagnosisTermListByGrade,
  reqSeniorInquiryList,
  reqSeniorInquiryUpdate,
  reqSymptomList,
  reqSymptomListByGrade
} from '@/services/firstConsultation';
import MedicalRecordItem from './components/MedicalRecordItem'

import styles from './index.module.less'


const MedicalRecord = ({
  defaultValue,
  onChange,
  isRadio,
  user
}: {
  value?: any,
  defaultValue?: any,
  onChange?: Function,
  isRadio?: boolean | undefined,
}) => {

  const [options, setOptions] = useState([])

  async function init() {
    try {
      const res = await reqSeniorInquiryList({
        pageNum: 1,
        pageSize: 10,
        tyPatientId: user?.tyPatientId,
        // tyMedicalCaseId: user?.id
      })

      console.log('病历信息列表信息 :>> ', res?.data);
      if (res?.resultCode == '00000000') {
        setOptions(res?.data?.result)
      } else {
        message.error(`病历信息列表信息出错！${res?.message}`)
      }
    } catch (error: any) {
      message.error('病历信息列表信息出错！', error)
      console.log('病历信息列表信息出错！ :>> ', error);
    }
  }


  useEffect(() => {
    if (user?.id) {
      init()
    }
  }, [user])


  return (
    <>
      <div className={styles.timeBox}>
        <div className={styles.title}>病历</div>
        <div className={styles.timeList}>
          {
            /* new Array(20).fill(options) */options?.map((item, index) => (
            <MedicalRecordItem key={index} data={item} />
          ))
          }
        </div>
      </div>
    </>
  )
}

export default MedicalRecord